#include <numeric>
#include <list>
#include <vector>
#include <string>
#include <iostream>

using namespace std;

bool cmp(string, string);
bool compare_nocase (string first, string second);

void UniqueTest(){
	list<string> mylist;
	list<string>::iterator it;
	mylist.push_back ("one");
	mylist.push_back ("two");
	mylist.push_back ("Three");

	mylist.sort();

	cout << "mylist contains:";
	for (it=mylist.begin(); it!=mylist.end(); ++it)
	cout << " " << *it;
	cout << endl;

	mylist.sort(compare_nocase);

	cout << "mylist contains:";
	for (it=mylist.begin(); it!=mylist.end(); ++it)
	cout << " " << *it;
	cout << endl;

	/* ================================ */

	list<string> lst;
	lst.push_back("b");
	for(int i = 0; i < 10; i ++)
	{
		lst.push_back("aa");
	}
	
	lst.sort();
	lst.sort(cmp);

	lst.unique();
	//lst.unique(cmp);

	return;
}

bool cmp(string first, string second){
	if(first.length() <= second.length())
		return true;
	else
		return false;
}

// comparison, not case sensitive.
bool compare_nocase (string first, string second)
{
  unsigned int i=0;
  while ( (i<first.length()) && (i<second.length()) )
  {
    if (tolower(first[i])<tolower(second[i])) return true;
    else if (tolower(first[i])>tolower(second[i])) return false;
    ++i;
  }
  if (first.length()<second.length()) return true;
  else return false;
}